<?php
// osłania przed pustymi tytułami
$title = strlen($this->row['title'])
	? $this->row['title']
	: $this->row['name'];

!strlen($title) or $this->headTitle($title);

/* @var $headMeta Zend_View_Helper_HeadMeta */
$headMeta = $this->getHelper('headMeta');

!strlen($this->row['meta_keywords']) or $headMeta->setName('keywords', $this->row['meta_keywords']);
!strlen($this->row['meta_description']) or $headMeta->setName('description', $this->row['meta_description']);
?>
<div class="kx_site kx_display">
	<div class="kx_content"><?php print $this->getHelper('renderer')->render($this->row['content']);?></div>
</div>
<?php
if (count($this->attachments) < 1) {
	// nie ma dowiązań.. więc przerywam
	return;
}
?>
<ul class="kx_list">
<?php
	foreach ((array) $this->attachments as $row):
		$time_create = strtotime($row['time_create']);
?>
	<li class="kx_item kx_type_<?php print $row['type'] ?> <?php print $this->cycle(array('odd','even'))?>">

	<?php switch($row['type']):
		case 'news': ?>
		<div class="kx_time">
			<em class="kx_day"><?php print date('d', $time_create)?></em>
			<em class="kx_month"><?php print $this->translate(strtolower(date('F', $time_create)))?></em>
			<em class="kx_year"><?php print date('Y', $time_create)?></em>
		</div>
		<div class="kx_content">
			<h6 class="kx_title"><a href="<?php print $this->url(array('news' => $row['id'])) ?>"><?php print $row['name']?></a></h6>
			<div class="kx_description"><?php print $row['description']?></div>
		</div>
		<?php break; ?>

		<?php case 'album': ?>
		<div class="kx_time">
			<em class="kx_day"><?php print date('d', $time_create)?></em>
			<em class="kx_month"><?php print $this->translate(strtolower(date('F', $time_create)))?></em>
			<em class="kx_year"><?php print date('Y', $time_create)?></em>
		</div>
		<div class="kx_content">
			<h6 class="kx_title"><a href="<?php print $this->url(array('album' => $row['id'])) ?>"><?php print $row['name']?></a></h6>
			<div class="kx_description"><?php print $row['description']?></div>
			<ul class="kx_gallery_images kx_list">
				<?php foreach ($row['album'] as $data):?>
					<?php if (isset($data['media'])):?>
						<li class="kx_item kx_gallery_type_media">
							<a rel="lightbox" href="<?php print $this->url(array('module'=>'gallery','controller' => 'media', 'action' => 'display', 'id' => $data['id']), 'default', true)?>">
								<img src="/upload/media/small/<?php print $data['image']?>" /></a></li>
					<?php else:?>
						<li class="kx_item kx_gallery_type_image">
							<a rel="lightbox" href="/upload/gallery/normal/<?php print $this->escape($data['image'])?>">
								<img src="/upload/gallery/small/<?php print $data['image']?>" /></a></li>
					<?php endif;?>

				<?php endforeach;?>
			</ul>
		</div>
		<?php break; ?>

	<?php endswitch; ?>
	
	</li>
<?php endforeach;?>
</ul>

<?php
	if (null !== $this->paginator)
		print $this->paginationControl($this->paginator,'Sliding','_partial/newsPagination.phtml');
?>